home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / fft / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-22  |  3.2 KB  |  127 lines

  1. /* fft/test.c
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #include <config.h>
  21. #include <string.h>
  22. #include <stddef.h>
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25. #include <math.h>
  26. #include <float.h>
  27.  
  28. #include <gsl/gsl_complex.h>
  29. #include <gsl/gsl_errno.h>
  30. #include <gsl/gsl_dft_complex.h>
  31. #include <gsl/gsl_fft_complex.h>
  32. #include <gsl/gsl_fft_complex_float.h>
  33. #include <gsl/gsl_fft_real.h>
  34. #include <gsl/gsl_fft_real_float.h>
  35. #include <gsl/gsl_fft_halfcomplex.h>
  36. #include <gsl/gsl_fft_halfcomplex_float.h>
  37. #include <gsl/gsl_ieee_utils.h>
  38. #include <gsl/gsl_test.h>
  39.  
  40. void my_error_handler (const char *reason, const char *file,
  41.                int line, int err);
  42.  
  43. #include "complex_internal.h"
  44.  
  45. /* Usage: test [n]
  46.    Exercise the fft routines for length n. By default n runs from 1 to 100.
  47.    The exit status indicates success or failure. */
  48.  
  49. #define BASE_DOUBLE
  50. #include "templates_on.h"
  51. #include "compare_source.c"
  52. #include "bitreverse.c"
  53. #include "test_complex_source.c"
  54. #include "test_real_source.c"
  55. #include "test_trap_source.c"
  56. #include "templates_off.h"
  57. #undef  BASE_DOUBLE
  58.  
  59. #define BASE_FLOAT
  60. #include "templates_on.h"
  61. #include "compare_source.c"
  62. #include "bitreverse.c"
  63. #include "test_complex_source.c"
  64. #include "test_real_source.c"
  65. #include "test_trap_source.c"
  66. #include "templates_off.h"
  67. #undef  BASE_FLOAT
  68.  
  69. int
  70. main (int argc, char *argv[])
  71. {
  72.   size_t i;
  73.   size_t start = 1, end = 99;
  74.   size_t stride ;
  75.   size_t n = 0;
  76.  
  77.   gsl_ieee_env_setup ();
  78.  
  79.   if (argc == 2) 
  80.     n = strtol (argv[1], NULL, 0);
  81.  
  82.   if (n)
  83.     {
  84.       start = n ;
  85.       end = n ;
  86.     }
  87.  
  88.  
  89.   for (i = 1 ; i <= end ; i *= 2) 
  90.     {
  91.       if (i >= start) 
  92.     {
  93.       for (stride = 1 ; stride < 4 ; stride++)
  94.         {
  95.           test_complex_bitreverse_order (stride, i) ;
  96.           test_complex_radix2 (stride, i) ;
  97.           test_real_bitreverse_order (stride, i) ;
  98.           test_real_radix2 (stride, i) ;
  99.         }
  100.     }
  101.     }
  102.  
  103.   for (i = start ; i <= end ; i++) 
  104.     {
  105.       for (stride = 1 ; stride < 4 ; stride++)
  106.     {
  107.       test_complex_func (stride, i) ;
  108.       test_complex_float_func (stride, i) ;
  109.       test_real_func (stride, i) ;
  110.       test_real_float_func (stride, i) ;
  111.     }
  112.     }
  113.  
  114.   gsl_set_error_handler (&my_error_handler);
  115.   test_trap () ;
  116.   test_float_trap () ;
  117.  
  118.   exit (gsl_test_summary ());
  119. }
  120.  
  121.  
  122. void
  123. my_error_handler (const char *reason, const char *file, int line, int err)
  124. {
  125.   if (0) printf ("(caught [%s:%d: %s (%d)])\n", file, line, reason, err) ;
  126. }
  127.